package thread;

//通过饿汉模式构造单例模式
class Singleton{
    private static Singleton instance = new Singleton();//（）内可加数字//静态成员的初始化是在类加载的阶段触发的

    public static Singleton getInstance(){
        return instance;
    }

    private Singleton(){

    }//单例模式中的 点睛之笔 在类外进行new操作都会编译失败


    private Singleton(int n){

    }
}

public class Demo28 {
    public static void main(String[] args) {
        Singleton t1 = Singleton.getInstance();
        Singleton t2 = Singleton.getInstance();
        System.out.println(t1 == t2);

        //Singleton t3 = new Singleton();
    }
}
